package org.slf4jx.core;

import org.slf4j.Logger;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 所需要的静态数据context
 * @author jjliu
 * @date 2023/1/13
 */
public class Slf4jxStaticContext {
    /** 包装后的logger */
    public static Map<String, Logger> loggerMap = new ConcurrentHashMap<>();

    /** 日志函数  动作名，函数标识，Method */
    public static Map<String,Map<String, Method>> methodMap = new HashMap<>();
    static {
        staticInit();
    }
    /** 收集 methodMap */
    public static void staticInit(){
        for(Method method : Logger.class.getMethods()){
            methodMap.computeIfAbsent(method.getName(),n->new HashMap<>())
                    .put(Slf4jxUtils.parametersAsString(method),method);
        }
    }

}
